<@override name="title">${_title_!}</@override>

<@override name="viewbody">
<!-- Page title -->
<div class="row">
    <div class="col-md-12">
        <h3 class="page-title">
            ${_title_}
            <small>${_small_!}</small>
        </h3>
        <ul class="page-breadcrumb breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="${ctx}/admin/home">
                    首页
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="#">
                    ${_li2_!}
                </a>
            </li>
        </ul>
    </div>
</div>
<!-- /page title -->
<div id="tip">
    <#if ok_message??>
        <div class="alert alert-success fade in widget-inner" id="alert">
            <button type="button" class="close" data-dismiss="alert">×</button>
        ${ok_message}
        </div>
    </#if>
    <#if error_message??>
        <div class="alert alert-warning fade in widget-inner" id="alert">
            <button type="button" class="close" data-dismiss="alert">×</button>
        ${error_message}
        </div>
    </#if>
</div>
<!-- Form validation -->
<div class="form-horizontal">
    <form action="<#if menu?? && menu=='true'>${ctx}/admin/wx/menu/messageSave"<#else>${ctx}/admin/wx/message/save"</#if> id="typeTextForm" method="post" enctype="multipart/form-data">
    <input type="hidden" name="id" value="${id!}"/>
    <input type="hidden" name="register" value="${register!}"/>
    <input type="hidden" name="menu" value="${menu!}"/>

    <div class="panel panel-default">
        <div class="panel-heading"><h6 class="panel-title">${_head_}</h6></div>
        <div class="panel-body" id="form-body">
            <#if register != 'true'>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="account.wx_account">关键字: </label>
                <div class="col-sm-10">
                    <input type="text" class="form-control required" id="keyword" name="keyword" <#if menu?? && menu=='true'>readonly </#if> value="${keyword!}"/>
                </div>
            </div>
            </#if>

            <div class="form-group">
                <label class="col-sm-2 control-label" for="account.wx_account">消息类型: </label>
                <div class="col-sm-10">
                    <div class="radio-list">
                        <label class="radio-inline">
                            <input type="radio" name="message_type" value="text" <#if message_type?? && message_type=='text'>checked="checked" </#if>> 文本消息
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="message_type" value="news" <#if message_type?? && message_type=='news'>checked="checked" </#if>> 图文消息
                        </label>
                    </div>
                    <#--<select class="form-control" name="message_type">
                        <option value="text" <#if message_type?? && message_type=='text'>selected="selected" </#if>>文本消息</option>
                        <option value="news" <#if message_type?? && message_type=='news'>selected="selected" </#if>>图文消息</option>
                    </select>-->
                </div>
            </div>

            <div id="type-1" <#if message_type?? && message_type=='news'>style="display: none;" </#if>>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="textcontent">消息内容: </label>
                    <div class="col-sm-10">
                        <textarea class="form-control required" rows="3" name="textcontent">
                            <#if message??>${message.content!}</#if>
                        </textarea>
                    </div>
                </div>
            </div>

            <div id="type-2" <#if message_type?? && message_type=='text'>style="display: none;" </#if>>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        <a class="btn green" id="addItem">添加一条图文消息</a>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        <div id="typeTwoEls">
                            <#if message_type?? && message_type=='text'>
                                <div class="panel panel-success" id="id1" name="item">
                                    <div class="panel-title text-right">
                                        <a href="javascript:void(0);" class="btn btn-xs" panel="id1" name="remove">
                                            <i class="fa fa-times"></i> 删除
                                        </a>
                                    </div>
                                    <div class="form-body">
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">标题</label>
                                            <div class="col-md-8">
                                                <input type="text" class="form-control required" name="title1" placeholder="标题">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">链接URL</label>
                                            <div class="col-md-8">
                                                <input type="text" class="form-control" name="url1" placeholder="链接URL">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">封面</label>
                                            <div class="col-md-8">
                                                <input name="file1" type="file" multiple="true">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">内容</label>
                                            <div class="col-md-8">
                                                <textarea class="form-control required" rows="3" name="content1"></textarea>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <#else>
                            <#if message??>
                                <#if message.articles??>
                                    <#list message.articles as a>
                                        <div class="panel panel-success" id="id${a_index}" name="item">
                                            <div class="panel-title text-right">
                                                <a href="javascript:void(0);" class="btn btn-xs" panel="id${a_index}" name="remove">
                                                    <i class="fa fa-times"></i> 删除
                                                </a>
                                            </div>
                                            <div class="form-body">
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">标题</label>
                                                    <div class="col-md-8">
                                                        <input type="text" class="form-control required" value="${a.title!}" name="title${a_index}" placeholder="标题">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">链接URL</label>
                                                    <div class="col-md-8">
                                                        <input type="text" class="form-control" value="${a.url!}" name="url${a_index}" placeholder="链接URL">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">封面</label>
                                                    <div class="col-md-8">
                                                        <input name="file${a_index}" type="file" multiple="true">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">描述</label>
                                                    <div class="col-md-8">
                                                        <textarea class="form-control required" rows="3" name="content${a_index}">${a.description!}</textarea>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </#list>
                                </#if>
                            </#if>
                            </#if>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <div class="form-actions text-right">
        <input type="submit" id="save" value="保存" class="btn btn-primary">
    </div>
    </form>
</div>

<script id="alert-template" type="text/x-handlers-template">
    <div class="alert {{classname}} fade in widget-inner" id="alert">
        <button type="button" class="close" data-dismiss="alert">×</button>
        {{message}}
    </div>
</script>

<script id="news-template" type="text/x-handlers-template">
    <div class="panel panel-success" id="{{id}}" name="item">
        <div class="panel-title text-right">
            <a href="javascript:void(0);" class="btn btn-xs" panel="{{id}}" name="remove">
                <i class="fa fa-times"></i> 删除
            </a>
        </div>
        <div class="form-body">
            <div class="form-group">
                <label class="col-md-2 control-label">标题</label>
                <div class="col-md-8">
                    <input type="text" class="form-control required" name="{{title}}" placeholder="标题">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label">链接URL</label>
                <div class="col-md-8">
                    <input type="text" class="form-control" name="name="{{url}}"" placeholder="链接URL">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label">封面</label>
                <div class="col-md-8">
                    <input name="{{file}}" type="file" multiple="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label">内容</label>
                <div class="col-md-8">
                    <textarea class="form-control required" rows="3" name="{{content}}"></textarea>
                </div>
            </div>
        </div>
    </div>
</script>
</@override>

<@override name="viewparams">
g.newstpl = '#news-template';
g.alerttpl = '#alert-template';
g.register = '${register!}';
g.menu = '${menu!}';
</@override>

<@override name="viewmodule">message_item</@override>
<@extends name="../../_basic/main.ftl"></@extends>


